package com.tsing.service.impl;

import com.tsing.common.result.PageResult;
import com.tsing.mapper.AppUserMapper;
import com.tsing.mapper.AuthMapper;
import com.tsing.mapper.impl.AppUserMapperImpl;
import com.tsing.mapper.impl.AuthMapperImpl;
import com.tsing.pojo.dto.TlUserDTO;
import com.tsing.pojo.entity.TlUser;
import com.tsing.service.AuthService;

/**
 * @author 吴阳基
 * @datetime 2023/12/4 18:50
 */
public class AuthServiceImpl implements AuthService {
    private final AuthMapper authMapper = new AuthMapperImpl();
    private final AppUserMapper appUserMapper = new AppUserMapperImpl();

    @Override
    public PageResult<TlUser> list(Integer page, Integer size, Integer status) {
        return authMapper.list(page, size, status);
    }

    @Override
    public int pass(Integer id) {
//        try {
//            DatabaseUtil.getConnection().commit();
//        } catch (SQLException e) {
//            throw new RuntimeException(e);
//        }

        //9 代表审核通过
        return authMapper.update(id, 1);
    }

    @Override
    public int fail(Integer id) {
//        try {
//            DatabaseUtil.getConnection().commit();
//        } catch (SQLException e) {
//            throw new RuntimeException(e);
//        }

        //2 代表审核失败
        return authMapper.update(id, 0);
    }

    @Override
    public int update(TlUserDTO tlUserDTO) {
        return appUserMapper.update(tlUserDTO);
    }
}
